package com.example.igela;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;

@SuppressLint("NewApi")
public class AlertDecisionDialog extends DialogFragment {

	
	public static AlertDecisionDialog newInstance (String titulo, String mensaje){
		
		AlertDecisionDialog fragment=new AlertDecisionDialog();
		Bundle args=new Bundle();
		args.putString("titulua", titulo);
		args.putString("mezua", mensaje);
		
		fragment.setArguments(args);
		return fragment;
		
	}
	
	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		
		String titulo = getArguments().getString("titulua");
		String mensaje = getArguments().getString("mezua");
		AlertDialog.Builder builderDialog=new AlertDialog.Builder(getActivity());
		builderDialog.setTitle(titulo);
		
		// Asignacion de titulo
		builderDialog.setTitle(titulo);
		// Asignacion de mensajes
		builderDialog.setMessage(mensaje);
		
		//Baietz botoia deklaratzen da
		//android.R.string.ok--> "Bai" jartzen duen lekuan jarri daiteke, mezu bat jarri nahi ez bada 
		builderDialog.setPositiveButton("Bai",new DialogInterface.OnClickListener(){ 
			@Override
			public void onClick(DialogInterface dialog, int which) { 
				((ErregistratuEtaGerokoPantaila)getActivity()).ezabatu();
			} 
		}); 
		// Ezetz botoia deklaratzen da
		//android.R.string.cancel--> "Ez" jartzen duen lekuan jarri daiteke, mezu bat jarri nahi ez bada
		builderDialog.setNegativeButton("Ez",new DialogInterface.OnClickListener(){  
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dismiss();
			} 
		}); 
		return builderDialog.create(); 
	} 
}
